import React, { useEffect } from 'react'
import { useLocation, useNavigate } from 'react-router-dom'

function useDurouter() {
    const nav = useNavigate()
    const { pathname } = useLocation()
    useEffect(() => {
        const token = localStorage.getItem('token')
        const bai = ['/index/order/orderadd', '/index/order/orderlist']
        if (!token && !bai.includes(pathname)) {
            nav('/')
        }
    }, [])
}

export default useDurouter
